package com.zline.foodraise.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.ViewGroup;

import com.zline.foodraise.entity.ProductBean;
import com.zline.foodraise.view.ProductViewPageCardItem;
import com.zline.foodraise.view.ProductViewPageCardItem_;
import com.zline.foodraise.view.RecyclerViewLoadMore_;

import org.androidannotations.annotations.EBean;
import org.androidannotations.annotations.RootContext;

/**
 * Created by heshantao on 15/6/27.
 * 我下面的商品Adapter
 */
@EBean
public class ProductViewPageRecycleAdapter extends LoadRecyclerBaseAdapter<ProductBean, ProductViewPageCardItem> {
    private static final String LOG_TAG=ProductViewPageRecycleAdapter.class.getSimpleName();
    @RootContext
    Context cxt;

    @Override
    protected ProductViewPageCardItem onCreateItemView(ViewGroup parent, int viewType) {
        return ProductViewPageCardItem_.build(cxt);
    }

    @Override
    protected BottomWrapper onCreateBottomView(ViewGroup parent, int viewType) {
        return new BottomWrapper(RecyclerViewLoadMore_.build(cxt));
    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
        if (holder instanceof ContentWrapper) {
            ProductViewPageCardItem view = (ProductViewPageCardItem) ((ContentWrapper) holder).getView();
            ProductBean productBean = (ProductBean) arrys.get(position);
            view.setListener(itemClicked);
            view.bind(productBean,position);
        }

    }
}
